<?php
namespace app\api\controller\uploade;
use think\Request;
use app\admin\server\uploade\Uploade as UploadeServer;
use think\config;
use app\admin\common;
use think\facade\Session;
use think\facade\View;
/**
 * @title 上传图片类
 */
class Uploade {
	protected $request;
	public static $server;
	
	  public function __construct(request $request)
    {
    	$this->request=$request;
    	self::$server=new UploadeServer($request);
        
    }
	/**
	 * @title 上传文件
	 * @return bool true/false 
	 */
	public function LayUploadFile(){
		return $this->commonFunction(__function__);
	}
	/**
	 * @title 上传图片
	 */
	public function uploadeImage(){
		return $this->commonFunction(__function__);
	}
	/**
	 * @title 公有方法
	 */ 
	private function commonFunction($function){
		$data=self::$server->$function();
		if($data==false){
			$result['code']=1;
			$result['data']['src']=$data;
			$result['data']['name']="files";
		}else{
			$result['code']=0;
			$result['data']['src']=$data;
			$result['data']['name']="files";
		}
		echo json_encode($result);exit;
		if($data==false){
			return common::return_json($data,self::$server->error,self::$server->code);
		}else{
			return common::return_json($data,self::$server->success,self::$server->code);
		}
	}

	 
}
?>